1783A - Make it Beautiful - CodeForces Solution


constructive algorithms sortings

Please click on ads to support us..

Python Code:


def ii(num=False):
    i = input().split()
    if num:
        return int(i[0])
    try:
        return list(map(int, i))
    except Exception:
        return i


def gcd(a, b):
    if a == 0:
        return b
    return gcd(b % a, a)

for _ in range(ii(1)):
    n = ii(1)
    a = ii()
    a.sort()
    if a[0]==a[-1]:
        print("NO")
        continue
    a[1], a[-1] = a[-1], a[1]
    print("YES")
    print(*a, sep=' ')


Comments

Submit
0 Comments
More Questions

Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game
Char Sum
Two Strings
Anagrams
Prime Number
Lexical Sorting Reloaded
1514A - Perfectly Imperfect Array